package com.yequan.hbb.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.yequan.hbb.R;
import com.yequan.hbb.view.fragment.ques_page_fragment.DynamicFragment;
import com.yequan.hbb.view.fragment.ques_page_fragment.HotFragment;
import com.yequan.hbb.view.fragment.ques_page_fragment.UnRequsetFragment;

/**
 * Created by DingLong on 2016/10/13.
 */

public class QuesFragmentAdapter extends FragmentPagerAdapter {
    private String[] titles;
    private Context context;

    public QuesFragmentAdapter(FragmentManager fm,Context context) {
        super(fm);
        this.context = context;

            titles = new String[]{context.getString(R.string.dynamic), context.getString(R.string.hot), context.getString(R.string.unrequest)};

    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:

                fragment = DynamicFragment.newInstance(titles[position]);
                break;
            case 1:
                fragment = HotFragment.newInstance(titles[position]);
                break;
            case 2:
                fragment = UnRequsetFragment.newInstance(titles[position]);
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
